﻿using System.Collections.Generic;
using FixMath;
using UniFramework.Actor;

namespace UniFramework.Buff
{
	/// <summary>
	/// 角色身上运行着的Buff实体
	/// </summary>
	public class BuffObj
	{
		public BuffConfig buffConfig;
		public LogicActor release; //释放者
		public LogicActor target; //携带者
		public FixInt duration;//剩余多少时间
		public bool permanent; //标识是否是永久buff
		public int stack;
		public FixInt timeElapsed; //当前buff已经存在了多久
		public int tickedCnt = 0; //buff执行了多少次OnTicked
		public Dictionary<string, object> buffParam = new Dictionary<string, object>();

		public BuffObj(
			BuffConfig config, LogicActor release, LogicActor target, FixInt duration, int stack, bool permanent = false,
			Dictionary<string, object> buffParam = null
		)
		{
			this.buffConfig = config;
			this.release = release;
			this.target = target;
			this.duration = duration;
			this.stack = stack;
			this.permanent = permanent;
			if (buffParam != null)
			{
				foreach (KeyValuePair<string, object> kv in buffParam)
				{
					this.buffParam.Add(kv.Key, kv.Value);
				}
			}
		}
	}
}